# -*- coding: utf-8 -*-

from annoying.decorators import render_to
from django.contrib import messages
from django.shortcuts import redirect
from django.conf import settings

from keymgroup.models import Menu, SubMenu, Data


@render_to('base.html')
def main_view(request):
    ''' Главное отображение '''

    ctx = {}

    title = 'Key Marketing Group'

    data_list = []

    menus = Menu.objects.all()

    for m in menus:
        submenu = SubMenu.objects.filter(menu=m.pk)
        data = Data.objects.filter(menu=m.pk)
        i = m.pk - 1

        data_list.append((m, submenu, data, i))

    ctx.update({
        'title': title,
        'data_list': data_list,
        })
    return ctx
